package com.lzy.cloud.goods.service.GoodsServiceImpl;

import com.lzy.cloud.goods.dtos.ParamDto;
import com.lzy.cloud.goods.entity.Param;
import com.lzy.cloud.goods.mapper.ParamMapperExt;
import com.lzy.cloud.goods.service.ParamService;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by WIN7 on 2018/6/9.
 */
@Service
public class ParamServiceImpl implements ParamService{

    @Autowired
    ParamMapperExt paramMapperExt;

    @Override
    public Long add(ParamDto paramDto) {
        Param param = DozerUtils.map(paramDto, Param.class);
        return paramMapperExt.insertSelective(param)>0?param.getId():null;
    }

    @Override
    public Boolean delById(Long id) {
        return paramMapperExt.deleteByPrimaryKey(id)>0;
    }

    @Override
    public Boolean update(ParamDto paramDto) {
        return paramMapperExt.updateByPrimaryKeySelective(DozerUtils.map(paramDto,Param.class))>0;
    }

    @Override
    public List<ParamDto> selectList(ParamDto dto) {
        return paramMapperExt.selectList(dto);
    }

    @Override
    public ParamDto selectById(Long id) {
        return DozerUtils.map(paramMapperExt.selectByPrimaryKey(id),ParamDto.class);
    }

    @Override
    public ParamDto selectBySourceId(ParamDto paramDto) {
        return paramMapperExt.selectBySourceId(paramDto);
    }

    @Override
    public Boolean delByKeyTrue(ParamDto paramDto) {
        return paramMapperExt.delByKeyTrue(paramDto)>0;
    }


}
